
{

	use strict;

	my %g_config;

	#	get hold of the config gile location.  the \\ is called escaping meaning that the char
	#	after the first "\" is to be interpreted exactly as it is found.  if u don't do that,
	#	u get the escape character but not the actual "\".  talk about riddles but it does all
	#	make sense.

	my $g_config_file = "c:\\Temp\\config.txt";

	&countWords;

	#	main path

	sub countWords() {

		my $input_dir = &getConfigVal( "INPUT_DIR" );

		&workThruFiles( $input_dir );

		print "Completed\n";
	}

	sub workThruFiles() {

	}

	sub getConfigVal() {

		#	return the value for the given config key.

		my $key = shift @_;

		my $retval;

		#	load up the global config if not already loaded.
		if ( !%g_config ) {
			%g_config = &initConfig;

		}

		# check the entry exists and return if so
		if ( exists $g_config{$key} ) {

			$retval = $g_config{$key};
		}
		else {
			die "Encountered unexpected key=$key\n";
		}

		return $retval;
	}

	sub initConfig() {

		#	init the config hash.

		print "config file=$g_config_file\n";
		my $line;
		my @arr;
		my $key;
		my $val;
		my %l_config;

		if ( -e $g_config_file ) {

			unless ( open OPENED_CONFIG, "<$g_config_file" ) {
				die "Failed to open the file: $!";
			}

			while ( <OPENED_CONFIG> ) {

				$line = $_;

				chomp( $line );

				@arr = split /=/, $line;

				$key = @arr[0];

				$val = @arr[1];

				#
				$l_config{$key} = $val;

			}
		}
		else {

			die "Cannot find file $g_config_file\n";
		}

		#	dump the configuration to the log

		print "Begin dump of config hash\n";

		my	$cnt=0;
		while ( my ( $key, $val ) = each( %l_config ) ) {
			
			print "cnt=$cnt\n";
			print "$key=$val\n";
			$cnt++;
		}

		print "End dump of config hash\n";

		return %l_config;
	}
}

